package com.hziee.graduate.ticket.dao;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hziee.graduate.ticket.vo.UserVO;
import org.apache.ibatis.annotations.Param;
import com.hziee.graduate.ticket.entity.User;
import org.apache.ibatis.annotations.Select;

public interface UserDao extends BaseMapper<User> {

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<User> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<User> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<User> 实例对象列表
     * @return 影响行数
     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常，请自行校验入参
     */
    int insertOrUpdateBatch(@Param("entities") List<User> entities);

    @Select("select user_id as userId, cinema_address as unitAddress,nick,phone,unit_id as unitId,cinema_name as unitName from t_user u\n" +
            "join t_cinema c on u.unit_id = c.cinema_id\n" +
            "where u.del_flag = 0")
    List<UserVO> getUserVO();
}

